
export function judgeAreaFn(message, areaIdList, defAreaId) {
  let areaId = '';
  if(areaIdList.length === 0 && !defAreaId) {
    message.warning('请选择所属区域');
    return false;
  }else if(areaIdList.length !== 0 && areaIdList.length < 3) {
    message.warning('请选择至街道');
    return false;
  } else if (areaIdList.length > 0) {
    let len = areaIdList.length - 1;
    areaId = areaIdList[len];
  }else {
    areaId = defAreaId;
  }
  return areaId
}

export function judgePersonAreaFn(message, areaIdList, defAreaId, defMsg = '请选择所属区域') {
  let areaId = '';
  if(areaIdList.length === 0 && !defAreaId) {
    message.warning(defMsg);
    return false;
  }else if (areaIdList.length > 0) {
    let len = areaIdList.length - 1;
    areaId = [areaIdList[len]];
  }else {
    areaId = defAreaId;
  }
  return areaId
}

export function judgeDeviceFn(message, deviceList, buildId, floorId, areaId, tname) {
  if(deviceList.length === 0 && !buildId) {
    message.warning(tname ? `请选择${tname}` : '请选择所属建筑区域');
    return false;
  }
  if(deviceList.length === 0 && buildId) {
    return [buildId, floorId, areaId];
  }
  return deviceList;
}

export function judgeBrandFn(message, brandList, brandId, productId) {
  if(brandList.length === 0 && !brandId) {
    message.warning('请选择厂家和型号');
    return false;
  }
  if(brandList.length === 0 && brandId && productId) {
    return [brandId, productId];
  }
  return brandList;

}
